cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -g -O0 -std=c++11")

# Get the current working branch
execute_process(
  COMMAND git rev-parse --abbrev-ref HEAD
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE GIT_BRANCH
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the latest abbreviated commit hash of the working branch
execute_process(
  COMMAND git log -1 --format=%h
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE GIT_COMMIT_HASH
  OUTPUT_STRIP_TRAILING_WHITESPACE
)


configure_file(
  version.h.in
  ${CMAKE_BINARY_DIR}/version.h
)

include_directories(${CMAKE_BINARY_DIR})
include_directories(.)

add_subdirectory(share tmp/share)
add_subdirectory(logon tmp/logon)
add_subdirectory(server tmp/server)
add_subdirectory(auth tmp/auth)
add_subdirectory(bill tmp/bill)
add_subdirectory(billclient tmp/billclient)
add_subdirectory(robot tmp/robot)
add_subdirectory(test tmp/test)
add_subdirectory(gencode tmp/gencode)
